import 'package:FiduMart/generated/json/base/json_convert_content.dart';
import 'package:FiduMart/core/network/model/gift_entity.dart';

GiftEntity $GiftEntityFromJson(Map<String, dynamic> json) {
  final GiftEntity giftEntity = GiftEntity();
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    giftEntity.name = name;
  }
  final String? awardNum = jsonConvert.convert<String>(json['award-num']);
  if (awardNum != null) {
    giftEntity.awardNum = awardNum;
  }
  final String? icon = jsonConvert.convert<String>(json['icon']);
  if (icon != null) {
    giftEntity.icon = icon;
  }
  final int? startdate = jsonConvert.convert<int>(json['startdate']);
  if (startdate != null) {
    giftEntity.startdate = startdate;
  }
  final int? hiddendate = jsonConvert.convert<int>(json['hiddendate']);
  if (hiddendate != null) {
    giftEntity.hiddendate = hiddendate;
  }
  return giftEntity;
}

Map<String, dynamic> $GiftEntityToJson(GiftEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['name'] = entity.name;
  data['award-num'] = entity.awardNum;
  data['icon'] = entity.icon;
  data['startdate'] = entity.startdate;
  data['hiddendate'] = entity.hiddendate;
  return data;
}

extension GiftEntityExt on GiftEntity {
  GiftEntity copyWith({
    String? name,
    String? awardNum,
    String? icon,
    int? startdate,
    int? hiddendate,
  }) {
    return GiftEntity()
      ..name = name ?? this.name
      ..awardNum = awardNum ?? this.awardNum
      ..icon = icon ?? this.icon
      ..startdate = startdate ?? this.startdate
      ..hiddendate = hiddendate ?? this.hiddendate;
  }
}